# Maintainer: Evangelos Foutras <evangelos@foutrelis.com>

pkgname=openmp
pkgver=15.0.7
pkgrel=1
pkgdesc="LLVM OpenMP Runtime Library"
arch=('x86_64')
url="https://openmp.llvm.org/"
license=('custom:Apache 2.0 with LLVM Exception')
depends=('llvm-libs' 'libelf' 'libffi')
makedepends=('llvm' 'clang' 'cmake' 'ninja')
options=('!lto') # https://bugzilla.redhat.com/show_bug.cgi?id=1988155
_source_base=https://github.com/llvm/llvm-project/releases/download/llvmorg-$pkgver
source=($_source_base/openmp-$pkgver.src.tar.xz{,.sig}
        $_source_base/cmake-$pkgver.src.tar.xz{,.sig})
sha256sums=('3f168d38e7a37b928dcb94b33ce947f75d81eef6fa6a4f9d16b6dc5511c07358'
            'SKIP'
            '8986f29b634fdaa9862eedda78513969fe9788301c9f2d938f4c10a3e7a3e7ea'
            'SKIP')
validpgpkeys=('474E22316ABF4785A88C6E8EA2C794A986419D8A'  # Tom Stellard <tstellar@redhat.com>
              'D574BD5D1D0E98895E3BF90044F2485E45D59042') # Tobias Hieta <tobias@hieta.se>

prepare() {
  mv cmake{-$pkgver.src,}
  cd openmp-$pkgver.src
  mkdir build
}

build() {
  cd openmp-$pkgver.src/build

  local cmake_args=(
    -G Ninja
    -DCMAKE_BUILD_TYPE=Release
    -DCMAKE_INSTALL_PREFIX=/usr
    -DLIBOMP_INSTALL_ALIASES=OFF
  )
  cmake .. "${cmake_args[@]}"
  ninja
}

package() {
  cd openmp-$pkgver.src/build

  DESTDIR="$pkgdir" ninja install
  install -Dm644 ../LICENSE.TXT "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  rm "$pkgdir/usr/lib/libarcher_static.a"
}

# vim:set ts=2 sw=2 et:
